Upon processing of image data, sound data or the like, to suppress the size of intermediate data and output data, data compression by a run-length method is often performed. A representative run-length compression is PackBits compression described in TIFF specification.
The PackBits compression or run-length compression has been conventionally processed by software of processor or by hardware. Such PackBits compression is disclosed in, e.g., Japanese Patent Application Laid-Open No. 9-154021 (counterpart U.S. Pat. No. 6,215,558).
However, in a case where PackBits compression encoding is made only by software, the processing speed is low. That is, as PackBits compression encode processing is accompanied by plural conditional determinations, high speed processing cannot be performed if processing is to be made with only basic processor computation commands. If specialized hardware for PackBits compression encoding is provided in addition to the processor for data processing to increase the processing speed, an overhead occurs in the processor to access external hardware. For example, it becomes difficult to change a process flow for compression in fine data units.
Further, in a case where data immediately preceding PackBits compression encoding is outputted in reverse order of that of data to be inputted into the PackBits compression encoder, the processing speed is lowered due to data rearrangement, and further, a temporary buffer must be prepared for rearrangement. Such situation occurs when lateral image inversion processing is performed immediately before PackBits compression or when image processing with directionality such as error diffusion is performed in reverse order of input data order.